package com.bing.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.bing.dto.StudentDto;
import com.bing.entity.Student;
import com.bing.mapper.StudentMapper;
import com.bing.service.StudentService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 测试
 *
 * @author 方宗庆
 * @create 2017-12-12 9:57
 */
@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    /**
     * @Description 根据删除
     * @Author 方宗庆
     * @Date 2017/12/13 19:31
     */
    public int del(Integer id) {
        int del = studentMapper.deleteByPrimaryKey(id);
        return del > 0 ? 1200 : 1300;
    }

    /**
     * @Description 实现分页
     * @Author 方宗庆
     * @Date 2017/12/13 14:17
     */
    @Override
    public Page<Student> list(Page<Student> page, Integer id) {
        page.setRecords(studentMapper.list(page, id));
        return page;
    }

    /**
     * @Description 多表联查实现分页
     * @Author 方宗庆
     * @Date 2017/12/14 10:48
     */
    @Override
    public Page<StudentDto> findHobbies(Page<StudentDto> page, Integer id) {
        page.setRecords(studentMapper.findHobbies(page, id));
        return page;
    }
}